Repository navigation
fix(durable): keep timers across recovery and skip idle ticks - #236
Conversation
29736b8 to
c6e5aa6
Compare
c6e5aa6 to
f4697dc
Compare
f4697dc to
e653227
Compare
e653227 to
8db4d1e
Compare
8db4d1e to
cb8ca81
Compare
cb8ca81 to
6e0908c
Compare
6e0908c to
bd0e889
Compare
bd0e889 to
189e001
Compare
189e001 to
c02481a
Compare
c02481a to
a03ba52
Compare
1738b1a to
372a253
Compare
372a253 to
b33de98
Compare
|
Review results. One reviewer per dimension, each reading the others' findings. All seven dimensions have zero blockers on the latest round. Fixed along the way: the Handle's timer table now follows the scheduler, and each chained timer takes the deadline the scheduler armed. Replay aligns on each Record, so older journals with a misplaced settle read recover, including across a restart. Every fix has a test confirmed to fail without it. Fuzzing journals this PR writes found no mismatch in about 80,000 operations per run. Known limits, in the changelog: two kinds of older journal can't be repaired and can fail |
Start now arms the initial state's timers and carries them in the baseline. Recovery re-arms checkpointed timers before the tail replays, so one fired in the tail isn't missed, and StateAt re-arms the baseline's. A tick that fires nothing records nothing, so a timer loop no longer grows the journal; replay reads an older journal's idle tick Record as nothing fired, and a reading no replayed step consumed no longer reaches the live clock. An older journal's settle read placed in the next Record is left to #262. Relates to #214. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…tick An idle Tick dropped every reading in the clock buffer, including the one a parent Fire that Start's or Recover's actors drove took arming its timer. The next step journals that Fire, so replay armed its timer at a later reading. An idle Tick now drops only its own reads. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
Recover and StateAt now fail when a replayed tick fires a different number of timers than its Record's TickSteps, rather than replaying the following steps in another state. An older version's recovery that missed a checkpointed timer fired in its tail, then fired it again live, leaves such a journal. Docs now say which clock readings are journaled, that recovery re-arms timers before the tail, that Start arms timers on a failed entry, that an idle tick doesn't count toward WithCheckpointEvery, and what an older durable does with a baseline that carries timers. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
…ecords An older version's recovery re-armed a checkpoint's timers after the tail, so a journal it continued can record a tick firing a timer the tail had canceled, which replay keeps canceled. Journal format is now 3, and replay checks a tick's fired count only for a Record of format 3 or later, so such a journal recovers to the state that version reached. Docs say which readings Start and an idle Tick leave unjournaled, that Recover fails on a format-3 tick count mismatch, and what an older durable's Recover and StateAt do with a baseline's timers. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
An older tick that records a timer replay keeps canceled reads fewer readings than its Record holds, and the rest went to the next Record, so a later Recover replayed it at the wrong instants. Replay now skips past each Record's readings once it has replayed it, in Recover and StateAt. Docs say the tick-count check applies from journal format 3, in replayRecord, Recover, StateAt and Record's godoc. Signed-off-by: Ray Karnes <ray.karnes@stablekernel.com>
|
Review results. One AI reviewer per dimension, each in a clean context, plus a probe reviewer that tried to break the change with tests. Every dimension has zero blockers on its latest round, at cc13ba8. Fixed along the way:
Each fix has a test that fails with the fix reverted. Known and left open:
|
What this change does
Timers survive recovery, and idle ticks stop growing the journal.
Startarms the initial state's timers and carries them in the baseline. An instance started before this change keeps its initial timer unarmed. Start arms them even when the initial entry failed, as it already starts that state's services and actors.Recoverre-arms checkpointed timers before the tail replays, so a tail tick can fire them. A held replay clock keeps that arming from consuming a recorded reading.StateAtre-arms the baseline's timers the same way.WithCheckpointEvery. A stale owner finds out on its next real step, not on the idle tick.Recover.RecoverandStateAtfail when a tick of format 3 or later fires a different number of timers on replay than its Record says, rather than replaying the steps after it in another state. An older Record isn't checked (see below).Tickgodoc says a timer whose transition fails is reported only in itsFireResult.Err.Please check these:
Startnever armed one, even live.Tick. This PR leaves it inFireResult.Errand documents that. It's a suggestion: say if you'd ratherTickreturn it.Recoverre-armed a checkpoint's timers after the tail. So a journal it continued can record a timer the tail had fired or canceled firing again. A canceled one it revived usually fired into a refusal, and replays to the same state. If the state it was in then takes the timer's event, or the timer fired twice, replay diverges from that run with no error, as that version's own replay did. Nothing in a format-2 journal tells these apart, so none failsRecover. Replay also skips any reading such a tick leaves, so the next Record reads its own.durablere-arms a baseline's or checkpoint's timers only after the tail, so it silently misses one a tail tick fired. The CHANGELOG's "don't downgrade" note now names it.tickDriversFormatcan put a settle's clock read in the next Record, so replay can arm that timer at the wrong instant. That's durable: an older journal's misplaced settle clock read can arm a replayed timer at the wrong instant #262, and its four tests are skipped with that number.Known and left open: checkpoints still grow with trace history, and the size metric #214 question 9 proposes has no home yet.
DeliverToActorpasses no effects to the scheduler, so a state entered by delivery never arms its timer.Why
Startnever armed the initial state's timers, even live. A checkpointed timer that a tail tick fired was missed on replay. Every idle tick appended a Record.Relates to: #214
Evidence
On
GOTOOLCHAIN=go1.27.4:mage check(lint, race tests, govulncheck)go test -race ./...indurableThe older-journal tests build their journals at format 1, older than
tickDriversFormat, the kind of version that still recorded idle ticks. New tests pin the idle tick keeping a pending parent Fire's read, the format-3 tick-count check, and an older journal's revived timer recovering; each fails with its fix reverted.Checklist
git commit -s) per the DCOtype: subject)mage checkpasses locally (lint + race tests + govulncheck)